package com.cqtczh.qhd.driver.model;

import android.os.Handler;
import android.os.Message;
import android.util.Log;

import com.baidu.mapapi.search.route.DrivingRouteLine;
import com.baidu.mapapi.search.route.DrivingRouteResult;
import com.baidu.mapapi.search.route.OnGetRoutePlanResultListener;
import com.baidu.mapapi.search.route.TransitRouteResult;
import com.baidu.mapapi.search.route.WalkingRouteResult;

/**
 * * @author 作者 陈修园:
 * 
 * @date 创建时间：2015-4-25 上午9:50:37
 * @version 1.0
 * @parameter 计算路径
 * @since
 * @return 返回路线长度
 */
public class RoutePlanResult implements OnGetRoutePlanResultListener {

	public Handler handler;

	public void OnGetDistance(final GetDistance callback) {
		handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				// TODO Auto-generated method stub
				super.handleMessage(msg);
				callback.GetData((Integer) msg.obj);
			}
		};
	}

	@Override
	public void onGetDrivingRouteResult(DrivingRouteResult arg0) {
		// TODO Auto-generated method stub
		Log.v("获得数据", "onGetDrivingRouteResult");
//		Log.v("数据长度", "" + arg0.getRouteLines().size());
		if (arg0 != null) {
			int mi = 0;
			for (int i = 0; i < arg0.getRouteLines().size(); i++) {
				DrivingRouteLine drivingRouteLine = arg0.getRouteLines().get(i);
				mi = drivingRouteLine.getDistance();
				Log.v("获得距离长度-》RoutePlanResult---：" + i + ":", "" + mi);
			}
			Message msg = Message.obtain();
			msg.what = 1;
			msg.obj = mi;
			handler.sendMessage(msg);
		}
	}

	@Override
	public void onGetTransitRouteResult(TransitRouteResult arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onGetWalkingRouteResult(WalkingRouteResult arg0) {
		// TODO Auto-generated method stub

	}

	public interface GetDistance {
		public void GetData(int data);
	}

}
